package search;

import org.junit.Test;

/**
 * @author zhm
 * @date 2020/10/20
 */
public class SearchTest {

    @Test
    public void testBinaryTest(){
        int[] a  = {1,2,3,4,5,6,7,8,9};
        System.out.println(BinarySearch.search(a, 1));
        System.out.println(BinarySearch.search(a, 2));
        System.out.println(BinarySearch.search(a, 3));
        System.out.println(BinarySearch.search(a, 4));
        System.out.println(BinarySearch.search(a, 5));
        System.out.println(BinarySearch.search(a, 6));
        System.out.println(BinarySearch.search(a, 7));
        System.out.println(BinarySearch.search(a, 8));
        System.out.println(BinarySearch.search(a, 9));
    }

    @Test
    public void testFirstEqualValue(){
        int[] a = {1,2,2,2,2,3,3,4,5,6,6};
        System.out.println(BinarySearch.searchFirstEqualValue(a, 1));
        System.out.println(BinarySearch.searchFirstEqualValue(a, 2));
        System.out.println(BinarySearch.searchFirstEqualValue(a, 3));
        System.out.println(BinarySearch.searchFirstEqualValue(a, 4));
        System.out.println(BinarySearch.searchFirstEqualValue(a, 5));
        System.out.println(BinarySearch.searchFirstEqualValue(a, 6));
        System.out.println(BinarySearch.searchFirstEqualValue(a, 7));
    }

    @Test
    public void testLastEqualValue(){
        int[] a = {1,2,2,2,2,3,3,4,5,6,6};
        System.out.println(BinarySearch.searchLastEqualValue(a, 1));
        System.out.println(BinarySearch.searchLastEqualValue(a, 2));
        System.out.println(BinarySearch.searchLastEqualValue(a, 3));
        System.out.println(BinarySearch.searchLastEqualValue(a, 4));
        System.out.println(BinarySearch.searchLastEqualValue(a, 5));
        System.out.println(BinarySearch.searchLastEqualValue(a, 6));
        System.out.println(BinarySearch.searchLastEqualValue(a, 7));
    }

    @Test
    public void testSearchFirstBigValue(){
        int[] a = {1,2,2,2,2,3,3,4,5,6,6};
        System.out.println(BinarySearch.searchFirstBigValue(a, 0));
        System.out.println(BinarySearch.searchFirstBigValue(a, 1));
        System.out.println(BinarySearch.searchFirstBigValue(a, 2));
        System.out.println(BinarySearch.searchFirstBigValue(a, 3));
        System.out.println(BinarySearch.searchFirstBigValue(a, 4));
        System.out.println(BinarySearch.searchFirstBigValue(a, 5));
        System.out.println(BinarySearch.searchFirstBigValue(a, 6));
        System.out.println(BinarySearch.searchFirstBigValue(a, 7));


    }
}
